home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_11_1986_Transactor_Publishing.d64 / pop menu source (.txt) < prev    next >
Commodore BASIC  |  2023-02-26  |  12KB  |  561 lines

  1. 5 sys 700
  2. 6 .opt oo
  3. 10 ;*********************************
  4. 20 ;** window and pop menu manager **
  5. 30 ;**   by darren james spruyt    **
  6. 40 ;**                             **
  7. 50 ;**(c) 1985 by                  **
  8. 60 ;**         darren james spruyt **
  9. 90 ;*********************************
  10. 1000 ;define variables
  11. 1010 *=$c000
  12. 1015 lpickarea =$02
  13. 1020 xby4  =$0256
  14. 1030 yby4  =$0255
  15. 1040 avail =$0258
  16. 1050 line  =$0257
  17. 2000 start =*
  18. 2010 jmp tsprite     ;pick areas on
  19. 2020 jmp anpickarea  ;add new pick area
  20. 2025 jmp popmenu     ;pop menu
  21. 2030 jmp dpickarea   ;delete pick area
  22. 2040 jmp pareasoff   ;pick areas off
  23. 5000 f1 rts
  24. 10000 popmenu =*         ;popmenu entry
  25. 10002 ldy #0
  26. 10004 jsr getval         ;get four
  27. 10006 bmi f1             ;parameters
  28. 10008 lda pickheight     ;for input
  29. 10009 cmp #3             ;and check
  30. 10010 bcc f1             ;for minimum
  31. 10011 lda pickwidth      ;width and
  32. 10012 cmp #3             ;height
  33. 10013 bcc f1
  34. 10014 sty avail          ;set avail flg
  35. 10016 jsr getparam
  36. 10018 stx color          ;get color
  37. 10020 jsr $aefd          ;check comma
  38. 10022 jsr $ad9e          ;eval input
  39. 10024 ldy $65
  40. 10026 lda $64
  41. 10028 jsr $b6db          ;cln desc stk
  42. 10030 ldy #2
  43. 10032 lda ($64),y
  44. 10034 sta $48            ;get add hi
  45. 10036 dey
  46. 10038 lda ($64),y
  47. 10040 sta $47            ;get add lo
  48. 10050 lda $47
  49. 10052 bne en0            ;dec address
  50. 10054 dec $48            ;by one
  51. 10056 en0 dec $47        ;
  52. 10090 lda #0
  53. 10100 jsr copy1          ;copy section
  54. 10200 ldy #0
  55. 10210 jsr makep          ;make pntr
  56. 10220 ldx pickheight
  57. 10225 jsr colorline
  58. 10230 ldy pickwidth
  59. 10240 dey
  60. 10250 lda #$6e           ;"[174]"
  61. 10260 sta ($fb),y
  62. 10270 dey
  63. 10272 bmi en1
  64. 10280 lda #$40           ;"[192]"
  65. 10290 en2 sta ($fb),y
  66. 10300 dey
  67. 10302 bmi en1
  68. 10310 bne en2
  69. 10320 lda #$70           ;"[176]"
  70. 10330 sta ($fb),y
  71. 10340 en1 stx temp
  72. 10350 en1a lda #$28      ;
  73. 10360 ldx #$fb           ;
  74. 10370 jsr add            ;increase pntr
  75. 10375 jsr colorline
  76. 10380 ldx temp           ;line cntr
  77. 10390 dex
  78. 10400 beq en3            ;exit if done
  79. 10402 cpx #1             ;
  80. 10404 beq en6
  81. 10410 ldy #0
  82. 10420 lda #$5d           ;"[221]"
  83. 10430 sta ($fb),y
  84. 10440 en4 iny
  85. 10450 cpy pickwidth
  86. 10460 beq en5
  87. 10470 lda ($47),y        ;get char
  88. 10475 jsr corrascii
  89. 10480 sta ($fb),y        ;to screen
  90. 10490 jmp en4
  91. 10500 en5 dey
  92. 10510 lda #$5d           ;"[221]"
  93. 10515 sta ($fb),y
  94. 10520 stx temp
  95. 10530 lda pickwidth
  96. 10540 sec
  97. 10550 sbc #$02
  98. 10560 ldx #$47
  99. 10570 jsr add            ;inc pntr
  100. 10580 jmp en1a
  101. 10640 en6 ldy pickwidth  ;
  102. 10650 dey
  103. 10660 lda #$7d           ;"[189]"
  104. 10670 sta ($fb),y
  105. 10680 lda #$40           ;"[192]"
  106. 10690 en8 dey
  107. 10700 beq en7
  108. 10710 bmi en3
  109. 10720 sta ($fb),y
  110. 10730 jmp en8
  111. 10740 en7 lda #$6d       ;"[173]"
  112. 10750 sta ($fb),y
  113. 10760 ;
  114. 10800 en3 ldx #1         ;set to top
  115. 10810 ep3 jsr revline
  116. 10900 ep2 stx temp       ;save line
  117. 10905 jsr $ffe4          ;get char
  118. 10907 ldx temp
  119. 10910 cmp #"[145]            ;up?
  120. 10920 bne ep1
  121. 10930 ;up
  122. 10940 cpx #1             ;at [164]p[153]
  123. 10950 beq ep2            ;yes
  124. 10960 jsr revline        ;unrevrs line
  125. 10970 dex
  126. 10980 jmp ep3            ;up 1
  127. 11000 ep1 cmp #"        ;down?
  128. 11010 bne ep4
  129. 11012 txa
  130. 11014 clc
  131. 11016 adc #2
  132. 11020 cmp pickheight     ;at bottom
  133. 11030 beq ep2            ;yes
  134. 11040 jsr revline        ;unrevrs line
  135. 11050 inx
  136. 11060 jmp ep3            ;increase line
  137. 11100 ep4 cmp #$0d       ;is a return
  138. 11110 bne ep2            ;nope
  139. 11120 stx $0257          ;set line num
  140. 11130 lda #$80           ;copy back
  141. 11140 jsr copy1          ;data to sc
  142. 11150 lda #1             ;release pntr
  143. 11160 sta avail
  144. 11170 rts                ;back to basic
  145. 11499 ;
  146. 11500 colorline =*
  147. 11510 ldy pickwidth
  148. 11520 jsr imagepntrs     ;backup pntrs
  149. 11530 dey
  150. 11540 lda color          ;set line
  151. 11550 cl1 sta ($fd),y    ;according
  152. 11560 dey
  153. 11570 bpl cl1            ;finish
  154. 11580 rts
  155. 12000 copy1 sta dir
  156. 12005 lda #0             ;set ($22) to
  157. 12010 sta $22
  158. 12020 lda #$b0           ;$b000
  159. 12030 sta $23
  160. 12032 ldy #0
  161. 12034 jsr makep          ;make address
  162. 12040 lda $01
  163. 12050 and #%11111110
  164. 12060 sei                ;lock irqs
  165. 12070 sta $01            ;open the rom
  166. 12080 jsr imagepntrs
  167. 12100 ;transfer from ($fb) to ($22)
  168. 12110 ldx pickheight
  169. 12115 ep9 ldy pickwidth
  170. 12120 dey
  171. 12122 epb lda dir
  172. 12124 bpl epa
  173. 12126 lda ($22),y    ;copy from memory
  174. 12127 sta ($fb),y    ;to screen
  175. 12128 lda ($24),y
  176. 12129 sta ($fd),y
  177. 12130 jmp ep8
  178. 12132 epa lda ($fb),y;copy from screen
  179. 12134 sta ($22),y    ;to memory
  180. 12136 lda ($fd),y
  181. 12138 sta ($24),y
  182. 12150 ep8 dey
  183. 12160 bpl epb        ;finish line
  184. 12200 ;inc pntrs
  185. 12210 stx temp
  186. 12220 lda #$28       ;add $28 to $fb
  187. 12230 ldx #$fb
  188. 12240 jsr add
  189. 12250 lda #$28       ;add $28 to $fb
  190. 12260 ldx #$22
  191. 12270 jsr add
  192. 12275 jsr imagepntrs ;copy pntrs
  193. 12280 ldx temp
  194. 12290 dex
  195. 12300 bne ep9        ;finish all lines
  196. 12310 lda $01
  197. 12320 ora #%00000001
  198. 12330 sta $01        ;close roms
  199. 12340 cli
  200. 12400 rts            ;and finish up
  201. 12900 imagepntrs =*
  202. 12905 lda $22        ;backup ($22) to
  203. 12910 sta $24
  204. 12915 lda $23
  205. 12920 ora #$04
  206. 12925 sta $25        ;($24)
  207. 12930 lda $fb        ;backup ($fb) to
  208. 12935 sta $fd
  209. 12940 lda $fc
  210. 12945 and #$03
  211. 12950 ora #$d8
  212. 12955 sta $fe        ;($fd)
  213. 12960 rts
  214. 13000 revline  =*
  215. 13020 ldy #0         ;
  216. 13030 txa            ;.x holds line
  217. 13032 sta temp
  218. 13040 clc
  219. 13050 adc pareay     ;add pick offset
  220. 13055 tax
  221. 13060 jsr makep1     ;make pntr
  222. 13070 ldy pickwidth  ;get width of line
  223. 13080 dey
  224. 13082 dey
  225. 13090 rvl1 lda ($fb),y
  226. 13100 eor #$80       ;reverse char
  227. 13110 sta ($fb),y    ;back to sc
  228. 13120 dey
  229. 13130 bne rvl1       ;finish line
  230. 13135 ldx temp       ;restore .x
  231. 13140 rts
  232. 14999 ;
  233. 15000 dpickarea =*
  234. 15010 jsr getparam   ;get pick are
  235. 15020 cpx #17
  236. 15030 bcs ep7        ;error so exit
  237. 15050 lda #0
  238. 15060 sta pareasopen,x;delete with 0
  239. 15070 rts            ;done
  240. 15080 ep7 lda #$ff   ;error return
  241. 15090 rts
  242. 15989 ;
  243. 15999 pareasoff =*   ;turn areas off
  244. 16000 lda $d015
  245. 16010 and #%01111111
  246. 16020 sta $d015      ;turn of sprite
  247. 16030 sei
  248. 16040 lda #$ea
  249. 16050 sta $0315      ;reset irq
  250. 16060 lda #$31
  251. 16070 sta $0314      ;vector and
  252. 16080 cli
  253. 16090 rts            ;exit
  254. 16999 ;
  255. 19000 add =*         ;add routine
  256. 19010 clc
  257. 19020 adc $00,x      ;add value in .a
  258. 19030 sta $00,x
  259. 19040 bcc add1       ;to indirect
  260. 19050 inc $01,x
  261. 19060 add1 rts       ;at $00,x
  262. 19069 ;
  263. 19100 corrascii =*   ;correct ascii
  264. 19110 cmp #$40
  265. 19120 bcc cr1        ;characters
  266. 19130 sbc #$40
  267. 19140 cr1 cmp #$80   ;before placing
  268. 19150 bcc cr2
  269. 19160 sbc #$40       ;on the screen
  270. 19170 cr2 rts
  271. 19999 ;
  272. 20000 anpickarea =*
  273. 20010 ldy #16
  274. 20014 an0 lda pareasopen,y
  275. 20016 beq an1
  276. 20020 dey
  277. 20022 bne an0
  278. 20040 lda #$fe
  279. 20060 ep6    rts
  280. 20100 an1 =*
  281. 20110 jsr getval
  282. 20120 bmi ep6
  283. 20130 sta pareasopen,y
  284. 20140 rts
  285. 20200 getval jsr getparam
  286. 20210 cmp #40
  287. 20220 bcs error
  288. 20230 sta pareax,y
  289. 20240 jsr getparam
  290. 20250 cmp #25
  291. 20260 bcs error
  292. 20270 sta pareay,y
  293. 20280 jsr getparam
  294. 20285 beq error
  295. 20290 sta pickwidth,y
  296. 20292 clc
  297. 20294 adc pareax,y
  298. 20296 cmp #40
  299. 20298 bcs error
  300. 20300 jsr getparam
  301. 20305 beq error
  302. 20307 sta pickheight,y
  303. 20310 clc
  304. 20312 adc pareay
  305. 20314 cmp #25
  306. 20316 bcs error
  307. 20320 lda #1
  308. 20340 rts
  309. 20350 error =*
  310. 20360 lda #$ff
  311. 20380 rts
  312. 29000 irqentry =*
  313. 29100 lda #>retcall      ;
  314. 29110 pha
  315. 29120 lda #<retcall      ;set fake irq
  316. 29130 pha
  317. 29140 php                ;call data
  318. 29150 pha
  319. 29160 pha
  320. 29170 pha
  321. 29200 jmp $ea31          ;do irq
  322. 29500 retcall =*         ;back here
  323. 29510 lda avail          ;is ok
  324. 29520 bne rr1            ;yes
  325. 29530 ex1 jmp $febc      ;finish irq
  326. 29600 rr1 lda $9d        ;in basic
  327. 29610 bmi ex1            ;nope
  328. 29612 lda $cc            ;cursor on
  329. 29614 beq ex1            ;yes - exit
  330. 29620 ldy $c6
  331. 29630 lda $0276,y        ;get last chr
  332. 29640 ldx #3
  333. 29650 af0 cmp tablea,x   ;check against
  334. 29660 beq af1            ;table
  335. 29670 dex
  336. 29680 bpl af0
  337. 29690 bmi af2
  338. 29700 af1  dec $c6       ;delete from
  339. 29710 af2  lda $cb       ;buffer + get
  340. 29720 cmp #$07
  341. 29730 beq af3
  342. 29740 cmp #$02
  343. 29750 bne ex1
  344. 29760 af3 and #$01
  345. 29763 ldy $028d
  346. 29765 beq cup
  347. 29770 cpy #3
  348. 29780 bcs ex1
  349. 29790 ora #$02
  350. 29800 jmp cup
  351. 30100 cup cmp #03        ;up
  352. 30110 bne cdown
  353. 30130 ldy ypos
  354. 30140 beq end            ;at top - ex
  355. 30145 dey
  356. 30150 sty ypos           ;decrease
  357. 30160 jmp end
  358. 30200 cdown cmp #1       ;down
  359. 30210 bne cleft
  360. 30230 ldy ypos
  361. 30240 cpy #99
  362. 30250 bcs end            ;at bottom -ex
  363. 30260 iny
  364. 30270 sty ypos           ;increase
  365. 30280 jmp end
  366. 30300 cleft cmp #02      ;left
  367. 30310 bne cright
  368. 30320 ;left
  369. 30330 ldy xpos
  370. 30340 beq end            ;at left - ex
  371. 30345 dey
  372. 30350 sty xpos           ;decrease
  373. 30360 jmp end
  374. 30400 cright cmp #00     ;right
  375. 30410 bne end
  376. 30420 ;right
  377. 30430 ldy xpos
  378. 30440 cpy #159           ;at right-ex
  379. 30450 bcs end
  380. 30460 iny
  381. 30470 sty xpos           ;increase
  382. 30500 end   =*
  383. 30510 lda $d010
  384. 30520 and #%01111111
  385. 30530 sta $d010          ;zero high bit
  386. 30540 lda xpos
  387. 30550 asl
  388. 30560 bcc ck6            ;x *2
  389. 30565 jsr setbit         ;set if ness.
  390. 30570 ck6 clc
  391. 30580 adc #24
  392. 30590 bcc ck7            ;add offset
  393. 30600 jsr setbit         ;set if ness.
  394. 30610 ck7 sta $d00e      ;set lo byte
  395. 30620 lda ypos           ;get ypos
  396. 30630 asl
  397. 30640 adc #50
  398. 30650 sta $d00f          ;set it
  399. 31000 lda xpos
  400. 31010 lsr
  401. 31020 lsr                ;/ xpos by 4
  402. 31030 sta xby4           ;to yield char
  403. 31040 lda ypos           ;positions
  404. 31050 lsr
  405. 31060 lsr                ;/ ypos by 4
  406. 31070 sta yby4           ;as above
  407. 31102 ldy #16            ;
  408. 31104 ck4 lda pareasopen,y
  409. 31105 beq ck3
  410. 31110 lda xby4
  411. 31120 cmp pareax,y
  412. 31130 bcc ck3            ;to the left
  413. 31150 sbc pareax,y
  414. 31160 cmp pickwidth,y
  415. 31170 bcs ck3            ;to the right
  416. 31180 lda yby4
  417. 31190 cmp pareay,y
  418. 31200 bcc ck3            ;above area
  419. 31210 sbc pareay,y
  420. 31220 cmp pickheight,y
  421. 31230 bcs ck3            ;below bottom
  422. 31240 cpy lpickarea      ;was last
  423. 31250 beq ck1            ;yes - no prob
  424. 31260 sty temp1          ;save new on
  425. 31270 ldy lpickarea      ;reverse last
  426. 31280 jsr revarea        ;pick area
  427. 31290 ldy temp1          ;get new area
  428. 31300 sty lpickarea      ;store cur pic
  429. 31310 jsr revarea        ;reverse area
  430. 31320 ck1 jmp $febc      ;exit irq
  431. 31350 ck3 dey            ;do all
  432. 31370 bne ck4            ;open picks
  433. 31380 ldy lpickarea      ;if none revrs
  434. 31390 jsr revarea        ;last area
  435. 31400 lda #0
  436. 31410 sta lpickarea      ;set to 0
  437. 31420 jmp $febc          ;done irq
  438. 31999 ;
  439. 32000 revarea  =*        ;
  440. 32002 tya
  441. 32004 beq dn1
  442. 32020 jsr makep          ;make pntr
  443. 32120 ldx pickheight,y
  444. 32130 lda pickwidth,y
  445. 32140 sta temp
  446. 32145 dec temp
  447. 32150 rv0 ldy temp
  448. 32160 rv1 lda ($fb),y   ;get char
  449. 32170 eor #$80          ;reverse
  450. 32180 sta ($fb),y       ;back to sc
  451. 32190 dey
  452. 32200 bpl rv1           ;finish line
  453. 32210 lda $fb
  454. 32220 clc
  455. 32230 adc #$28
  456. 32240 sta $fb
  457. 32250 bcc rv2
  458. 32260 inc $fc           ;increase pntr
  459. 32270 rv2 dex
  460. 32280 bne rv0           ;finish lines
  461. 32290 dn1 rts
  462. 38000 makep =*          ;make pointer
  463. 38010 ldx pareay,y
  464. 38020 makep1 lda $d9,x  ;at ($fb),
  465. 38030 and #$03
  466. 38040 ora $0288         ;to point
  467. 38050 sta $fc
  468. 38060 lda $ecf0,x       ;to screen line
  469. 38070 clc
  470. 38080 adc pareax,y      ;according to
  471. 38090 sta $fb
  472. 38100 bcc pn1           ;pick area in
  473. 38110 inc $fc
  474. 38120 pn1 rts           ;.y
  475. 39000 setbit =*         ;set msb of
  476. 39005 pha
  477. 39010 lda $d010         ;sprite pos
  478. 39020 ora #%10000000
  479. 39030 sta $d010
  480. 39035 pla
  481. 39040 rts
  482. 40000 tsprite =*        ;copy sprite
  483. 40010 ldy #63
  484. 40020 ts1 lda spritedata,y
  485. 40030 sta $03c0,y       ;to low memory
  486. 40040 dey
  487. 40050 bpl ts1
  488. 41010 sei               ;lock irq's
  489. 41020 lda #>irqentry
  490. 41030 sta $0315
  491. 41040 lda #<irqentry
  492. 41050 sta $0314         ;set vector
  493. 41060 cli
  494. 41100 lda #128
  495. 41110 sta 53248+21      ;turn on
  496. 41120 lda #15
  497. 41130 sta $07ff         ;set pic loc
  498. 41135 sta avail         ;set avail flg
  499. 41140 lda #0
  500. 41150 sta pareasopen    ;zero open
  501. 41152 sta lpickarea     ;set last pick
  502. 41154 sta xpos
  503. 41156 sta ypos          ;start pos
  504. 41160 lda #0
  505. 41170 ldy #16           ;clear flags
  506. 41180 ts2 sta pareasopen,y
  507. 41190 dey
  508. 41200 bpl ts2           ;for pick areas
  509. 41210 lda #24
  510. 41220 sta $d00e         ;set start
  511. 41230 lda #50
  512. 41240 sta $d00f
  513. 41410 rts               ;sprite pos
  514. 42000 getparam  =*
  515. 42010 sty temp
  516. 42020 jsr $aefd         ;check comma
  517. 42030 jsr $b79e         ;0-255 parameter
  518. 42040 ldy temp
  519. 42050 txa               ;return in .a
  520. 42060 rts
  521. 50000 spritedata =*
  522. 50010 .byte%11111110,%00000000,%00000000
  523. 50020 .byte%11100000,%00000000,%00000000
  524. 50030 .byte%11110000,%00000000,%00000000
  525. 50040 .byte%11011000,%00000000,%00000000
  526. 50050 .byte%11001100,%00000000,%00000000
  527. 50060 .byte%11000110,%00000000,%00000000
  528. 50070 .byte%00000011,%00000000,%00000000
  529. 50080 .byte%00000001,%00000000,%00000000
  530. 50100 .byte 0,0,0
  531. 50110 .byte 0,0,0
  532. 50120 .byte 0,0,0
  533. 50130 .byte 0,0,0
  534. 50140 .byte 0,0,0
  535. 50150 .byte 0,0,0
  536. 50160 .byte 0,0,0
  537. 50170 .byte 0,0,0
  538. 50180 .byte 0,0,0
  539. 50190 .byte 0,0,0
  540. 50200 .byte 0,0,0
  541. 50210 .byte 0,0,0
  542. 50220 .byte 0,0,0
  543. 50500 tablea .byte $11,$1d,$91,$9d
  544. 60000 ;internal variables
  545. 60010 ypos *=*+1
  546. 60030 xpos *=*+1
  547. 60050 pareasopen =*
  548. 60060 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  549. 60080 pareax =*
  550. 60090 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  551. 60100 pareay =*
  552. 60110 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  553. 60120 pickwidth =*
  554. 60130 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  555. 60140 pickheight =*
  556. 60150 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  557. 60200 temp *=*+1
  558. 60220 dir  *=*+1
  559. 60240 temp1 *=*+1
  560. 60500 color *=*+1
  561.